/*
 * @author: sanbao
 * @Date: 2022-07-22 14:42:29
 */
import * as icons from "@element-plus/icons"
const importFn = require.context('./', true, /\.vue$/)
export default {
    install(app: any) {
        // 批量注册全局组件
        importFn.keys().forEach(key => {
            // 导入组件
            const component = importFn(key).default
            // 注册组件
            app.component(component.name, component)
        })

        addComponents(app)
    }
}
// element icon 组件注册
function addComponents(APP: any) {
    let EL_ICON_OBJ: any = {
        ...icons
    }
    for (const key in EL_ICON_OBJ) {
        let component = getValue(key)
        APP.component(key, component)
    }
    function getValue(arg: keyof typeof EL_ICON_OBJ) {
        return EL_ICON_OBJ[arg]
    }
}

